package com.hmall.newskills;

/**
 * @ClassName Builder
 * @Description
 * @Author zhoutao
 * @Date 2018/12/26 9:41
 * @Version 2.0
 **/
public class Person {

    private int age;

    private String name;

    private String hight;

    private String sex;

    public static class Builder{
        private int age;
        private String name;
        private String hight;
        private String sex;

        public Builder age(int age){
            this.age = age;
            return this;
        }

        public Builder name(String name){
            this.name = name;
            return this;
        }

        public Builder hight(String hight){
            this.hight = hight;
            return this;
        }

        public Builder sex(String sex){
            this.sex = sex;
            return this;
        }

        public Person build(){
            return new Person(this);
        }
    }

    private Person(Builder builder){
        this.age = builder.age;
        this.hight = builder.hight;
        this.name = builder.name;
        this.sex = builder.sex;
    }

    @Override
    public String toString() {
        return "Person{" +
                "age=" + age +
                ", name='" + name + '\'' +
                ", hight='" + hight + '\'' +
                ", sex='" + sex + '\'' +
                '}';
    }
}
